import { CSSProperties } from 'react';
import { ComponentType } from '@/plugins/form/form-render/constants/component-types';

// 组件可见性的条件
export interface ICondition {
  componentType: ComponentType;
  conditionName: string;
  conditionValue: any;
}

export interface Option {
  value: string;
  text: string;
  disabled: boolean;
}

export interface Prop extends IterateAny {
  style?: CSSProperties;
  options?: Option[];
  code?: string;
  customCode?: string;
  required?: boolean;
  name: string;
  value?: any;
  permission?: PermissionFields;
  visibleConditions: ICondition[];
  // 被引用的关系 可能被流程作为条件引用，可能被表单作为条件引用，可能被流程节点作为权限引用
  formConditions?: string[]; // 引用表单的id
  bpmnConditions?: string[]; // 引用流程的id
  bpmnPermission?: { [index: string]: PermissionFields }; // 引用权限的对象数组
}

interface Data {
  props: Prop;
}

export type PermissionFields = 'editable' | 'readonly' | 'hide';

export interface IGaeaInstance extends IterateAny {
  isContainer?: boolean;
  isGroup?: boolean;
  isBasicGroup?: boolean;
  gaeaKey: string;
  data: Data;
  childs?: string[];
  parentInstanceKey: string;
}

export interface IGaeaAll {
  [index: string]: IGaeaInstance;
}
